package com.wc.alorithm_blue_bridge._模拟.Q4684;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congege
 * @Description 勇士的传奇：防御之道
 * https://www.lanqiao.cn/problems/4684/learning/?page=1&first_category_id=1
 * @Date Created in 2023/12/19-17:25
 */
public class Main {
    static FastReader in = new FastReader();

    public static void main(String[] args) {
        int n = in.nextInt();
        int k = in.nextInt();
        Man[] men = new Man[n];
        for (int i = 0; i < n; i++) {
            men[i] = new Man();
            men[i].a = in.nextInt();
            men[i].b = in.nextInt();
        }
        Arrays.sort(men);
        long ans = men[0].a > k ? 0 : men[0].b;
        for (int i = 1; i < n; i++) {
            if (men[0].a + men[i].a <=k ){
                ans += men[i].b;
            }else {
                break;
            }
        }
        System.out.println(ans);
    }

    static class Man implements Comparable<Man> {
        int a;
        int b;

        @Override
        public int compareTo(Man o) {
            return this.a - o.a;
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
}
